DATABASE_URL = 'mongodb://{% if alerta_mongod_auth | bool %}{{ alerta_mongod_user }}:{{ alerta_mongod_pass | urlencode }}@{% endif %}{{ alerta_mongod_hosts | list | join(":" + alerta_mongod_port + ",") }}:{{ alerta_mongod_port }}/ALERTA?{% if ( alerta_mongod_replset is defined ) and ( alerta_servers|length is not divisibleby 2 ) and ( alerta_servers|length > 2 ) %}replicaSet={{ alerta_mongod_replset | default("ALERTA") | upper }}&{% endif %}connectTimeoutMS=300000'
DATABASE_NAME = 'ALERTA'
DATABASE_RAISE_ON_ERROR = False
COLUMNS = ['severity', 'status', 'type', 'lastReceiveTime', 'duplicateCount', 'environment', 'group', 'resource', 'service', 'event', 'text']
CORS_ORIGINS = [ 'https?://\w*\:?\d*/?.*' ]
AUTH_REQUIRED = True
BASE_URL = '{{ alerta_arg.base_url }}'
USE_PROXYFIX = {{ alerta_arg.use_proxyfix }}
SECRET_KEY = '{{ lookup('password', '' + alerta_cluster + ':authentication:tokens length=32 chars=ascii_letters,digits') }}'
AUTH_PROVIDER = '{{ alerta_arg.auth_provider }}'
ADMIN_USERS = ['{{ alerta_admin_user }}']
SIGNUP_ENABLED = {{ alerta_arg.signup_enabled }}
SITE_LOGO_URL = '{{ alerta_arg.site_logo_url | default("") }}'
LOG_HANDLERS = ['console', 'file']
LOG_FILE = '/var/log/alerta/alertad.log'
LOG_MAX_BYTES = {{ alerta_arg.log_max_mib }}*1024*1024
LOG_BACKUP_COUNT = {{ alerta_arg.log_backup_count }}
LOG_FORMAT = '{{ alerta_arg.log_format }}'
ALLOWED_ENVIRONMENTS = ['{{ alerta_allowed_environments | list | join("','") }}']
{% if alerta_plugin_list is defined %}
PLUGINS = ['{{ alerta_plugin_list | list | join("','") }}']
PLUGINS_RAISE_ON_ERROR = False
{% endif %}
{% if alerta_plugin_list is defined and  'prometheus' in alerta_plugin_list %}
ALERTMANAGER_API_URL = '{{ (lookup('dict', alerta_plugins, wantlist=True ) | json_query('[?key==`prometheus`].value[0].alertmanager_api_url'))[0] | default('http://127.0.0.1:9093') }}'
ALERTMANAGER_SILENCE_DAYS = {{ (lookup('dict', alerta_plugins, wantlist=True ) | json_query('[?key==`prometheus`].value[0].alertmanager_silence_days'))[0] | default('2') }}
{% endif %}
